<?php

namespace console\controllers;

use Yii;
use yii\console\Controller;
use common\models\Command;
use common\models\Logger;
use common\models\SocketConnection;

/**
 * Command controller
 */
class CommandController extends Controller {

    /**
     * index Command
     *
     * @return 0
     */
    public function actionIndex() {
        $fp = SocketConnection::getContent();
        $time = time();
        while (time() < $time + 60) {
            Command::read();
            sleep(1);
        }
        return 0;
    }

    /**
     * Read Command
     *
     * @return 0
     */
    public function actionSensorWork() {
        $time = time();
        while (time() < $time + 60) {
            $count = Command::SensorWork();
            sleep(1);
        }
        return 0;
    }

    public function actionAlertWork() {
        $time = time();
        while (time() < $time + 60) {
            $count = Command::alertWork();
            sleep(1);
        }
        return 0;
    }

}
